package com.cyandpos.pad.report.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.cyandpos.pad.R;
import com.cyandpos.pad.posdata.ReportPay;

import java.util.List;

/**
 */

public class ListViewAdapter extends BaseAdapter {

    private List<ReportPay> paymentList;
    private LayoutInflater mInflater;

    public ListViewAdapter(List<ReportPay> paymentList, Context context) {
        this.paymentList = paymentList;
        mInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return paymentList.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {

            holder = new ViewHolder();
            convertView = mInflater.inflate(R.layout.report_item, null);
            holder.tv_name = (TextView) convertView.findViewById(R.id.tv_report_item_paymentname);
            holder.tv_money = (TextView) convertView.findViewById(R.id.tv_report_item_paiedmoney);
            holder.tv_count = (TextView) convertView.findViewById(R.id.tv_report_item_else);
            convertView.setTag(holder);

        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        if (position % 2 == 0) {
            convertView.setBackgroundColor(Color.rgb(241, 240, 245));
        } else {
            convertView.setBackgroundColor(Color.WHITE);
        }
        holder.tv_count.setText(paymentList.get(position).getAmount_yy());
        holder.tv_name.setText(paymentList.get(position).getName());
        holder.tv_money.setText(paymentList.get(position).getAmount());
        return convertView;
    }

    public final class ViewHolder {
        public TextView tv_name, tv_money, tv_count;
        public View view;
    }


}
